<template>
  <div>
    <div>
      <span>获取RSA 2048 公私钥！不保存</span>
      <span class="obtain">
        <el-button
          icon="el-icon-search"
          size="mini"
          type="primary"
          @click="obtain"
          >获取
        </el-button>
      </span>
      <div class="Top">
        <div class="keyText">公钥:</div>
        <div class="keyText-top">
          <el-input
            v-model="from.publicKey"
            :rows="3"
            type="textarea"
          ></el-input>
        </div>
      </div>
      <div class="Top">
        <div class="keyText">私钥:</div>
        <div class="keyText-top">
          <el-input v-model="from.Key" :rows="3" type="textarea"></el-input>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { generateKey } from "@/assets/js/homePage";

export default {
  data() {
    return {
      from: {
        publicKey: "",
        Key: "",
      },
    };
  },
  methods: {
    async obtain() {
      let res = await generateKey("");
      if (res.code === 200) {
        this.from.publicKey = res.data.publicKey;
        this.from.Key = res.data.privateKey;
      }
    },
  },
};
</script>
<style scoped>
.obtain {
  margin-left: 20px;
}

.Top {
  margin-top: 15px;
}

.keyText {
  font-weight: bold;
}

.keyText-top {
  margin-top: 5px;
}
</style>
